/**
*  ajax part
*/


 function mySend_request(url , flag){


		 var http_request=false;


	     if(window.XMLHttpRequest){//Mozilla
	         http_request=new XMLHttpRequest();
	         if(http_request.overrideMimeType){
	             http_request.overrideMimeType("text/xml");
	         }
	     }
	     else if(window.ActiveXObject){//IE
	         try{
	             http_request=new ActiveXObject("Msxml2.XMLHTTP");
	         }
	         catch(e){
	             try{
	                 http_request=new ActiveXObject("Microsoft.XMLHTTP");
	             }
	             catch(e){}
	         }
	     }

	     if(!http_request){
	         window.alert("can't create XMLHttpRequest!");
	         return false;
	     }
	         http_request.onreadystatechange=function(){myProcessRequest(http_request , flag)};
		     http_request.open("GET",url,true);
		     http_request.send(null);


	 }

var msgQueue = [];
var timeQueue = [];
function MsgNode(){
	this.id;
	this.timeOut;
	this.title;
	this.time;
	this.detail;
	this.repeat;
	this.remind;
}
	 function myProcessRequest(http_request , flag){
	 				
	     if(http_request.readyState==4){

	         if(http_request.status==200){
				var str = http_request.responseText;
				var xml = http_request.responseXML;

				if(xml != null && str.length > 0){

					if(flag == 2)
					{
						parseXmlTimeList(xml);
					}
					if(flag == 3)
					{
						add(xml);
					}
				}
				}



	     }
	 }



	  function parseXmlTimeList(xml){
		
		var xmlEle = xml.documentElement;

		var dataList = new Array();

		if (xmlEle) dataList = xmlEle.getElementsByTagName('msg');
		
		var dataLen = dataList.length;

		if(dataLen == 0) return 'false';

		for (i = 0; i < dataLen; i++) {
			
			var msgNode = new MsgNode();
		
			msgNode.id = dataList[i].childNodes[0].firstChild.nodeValue;//.firstChild;

			msgNode.timeOut = dataList[i].childNodes[1].firstChild.nodeValue;

			msgNode.title = dataList[i].childNodes[2].firstChild.nodeValue;

			msgNode.time = dataList[i].childNodes[3].firstChild.nodeValue;

			msgNode.detail = dataList[i].childNodes[4].firstChild.nodeValue;

			msgNode.repeat = dataList[i].childNodes[5].firstChild.nodeValue;

			msgNode.remind = dataList[i].childNodes[6].firstChild.nodeValue;

			msgQueue[i] = msgNode;

			timeQueue[i]=createTimer(msgNode , msgQueue.length-1);
			
		}

		return 'true';
}



function show(node , i)
{
 var obj = new Object();
 obj.node= node;
 obj.i = i;
 obj.msgQueue = msgQueue;

window.showModalDialog('pages/webframework/sec/Aux_worktable_msg_Rem.jsp',obj,'dialogWidth:650px;dialogHeight:300px;help:no;status:no;scroll:no;center');
}

 function add(xml)
 {
 	    var xmlEle = xml.documentElement;

		var dataList = new Array();

		if (xmlEle) dataList = xmlEle.getElementsByTagName('msg');

		var dataLen = dataList.length;

		if(dataLen == 0) return 'false';

		var msgNode = new MsgNode();

		msgNode.id = dataList[0].childNodes[0].firstChild.nodeValue;//.firstChild;

		msgNode.timeOut = dataList[0].childNodes[1].firstChild.nodeValue;

		msgNode.title = dataList[0].childNodes[2].firstChild.nodeValue;

		msgNode.time = dataList[0].childNodes[3].firstChild.nodeValue;

		msgNode.detail = dataList[0].childNodes[4].firstChild.nodeValue;

		msgNode.repeat = dataList[0].childNodes[5].firstChild.nodeValue;

		msgNode.remind = dataList[0].childNodes[6].firstChild.nodeValue;

		timeQueue[i]=createTimer(msgNode , msgQueue.length);

        msgQueue[msgQueue.length] =  msgNode;
 }

 function del(id)
 {
     var flag;

     for (i = 0; i < msgQueue.length; i++) {
	 	if((msgQueue[i]!=null)&&(msgQueue[i].id == id))
		{
			flag = i;
			break;
		}
    }

	if((flag!=null)&&(flag!=undefined)){
	clearTimeout(timeQueue[flag]);
		   msgQueue[flag] = null;
		   timeQueue[flag] = null;
		   	}

}

